home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / text / misc / WordConverter.lha / WordConverter / rexx / PGSImportWord.rexx < prev   
OS/2 REXX Batch file  |  1999-02-01  |  4KB  |  106 lines

  1. /*rx
  2.  *  $VER: PGSImportWord.rexx 1.0.2 (21.11.97) ©1997 Peter Drapich
  3.  *  This ARexx script is for use with PageStream 3 DTP package ©SoftLogik.
  4.  *
  5.  *  PGSImportWord.rexx is a part of WordConverter archive and imports texts from documents
  6.  *  created with Word for Windows or Mac into PageStream document.
  7.  *
  8.  *  During execution of this script, you'll be asked with the filerequester for the
  9.  *  source Word document filename.
  10.  *  This script uses WordConverter to convert Word documents into text.
  11.  *  If WordConverter isnt in the current path, you'll be prompted to select its current
  12.  *  location. 
  13.  *
  14.  *  WordConverter and PGSImportWord.rexx were written by Peter Drapich in 1997
  15.  *  and are shareware software copyrighted by Peter Drapich.
  16.  *
  17.  *  Email any remarks or new ideas to: docent@union.org.pl
  18.  *
  19.  */
  20.     options results
  21. /*    options failat 20*/
  22.     trace off
  23.     CR = '0A'X
  24.     ERR_REVUNKNOWN=6        /* these are internal error codes, returned by WordConverter */
  25.     ERR_NOTWORDFILE=8
  26.     IF ~show('L','rexxsupport.library') THEN
  27.         call addlib('rexxsupport.library',0,-30)
  28.     IF ~show('L','softlogik:libs/slarexxsupport.library') THEN
  29.         call addlib("softlogik:libs/slarexxsupport.library", 0, -30)
  30.     address 'PAGESTREAM'
  31. /* check and see if a text frame is selected */
  32.     getcursor type objtype
  33.     if RC>0 | objtype='TEXTOBJ' then do
  34.         call doalert('The insertion point must be in a text frame, please try again.')
  35.             exit 0
  36.     end
  37.     filename = 'WordConverter'
  38.     do while ~exists(filename)
  39.         getfile title "'Select the location of Word Converter'" LOAD POSBUTTON "OK" NEGBUTTON "Cancel"
  40.         if rc~=0 then exit 0
  41.         filename = result
  42.     end
  43.     filename = '"'||filename||'"'
  44.     getfile title "'Select the Word document to import'" LOAD POSBUTTON "Import" NEGBUTTON "Cancel"
  45.     if rc~=0 then exit 0
  46.     if (result = 'result') then do
  47.         call doalert 'No source filename was specified.'
  48.         exit 0
  49.     end
  50.     srcfilename = result
  51.     srcfilename = '"'||srcfilename||'"'
  52.     tempname = 'T:wordconv.temp'
  53.     commandrc=1
  54.     do while (commandrc)
  55.         address command filename srcfilename tempname
  56.         commandrc = rc
  57.         if commandrc=ERR_REVUNKNOWN then do
  58.             sMsgText='Unknown revision of Word document'
  59.             iMsgLength=length(sMsgText)
  60.             allocarexxrequester '"WordConverter"'  iMsgLength*8+20 65
  61.             hDialog=result
  62.             addarexxgadget hDialog EXIT 12 44 70 label "OK"
  63.             hDialog.ok=result
  64.             addarexxgadget hDialog EXIT 200 44 70 label "Cancel"
  65.             hDialog.cancel=result
  66.             addarexxgadget hDialog TEXT 8 12 iMsgLength*8+8 border none string '"'sMsgText'"'
  67.             sMsgText='Do you want to read it anyway ?'
  68.             iMsgLength=length(sMsgText)
  69.             addarexxgadget hDialog TEXT 16 22 iMsgLength*8+8 border none string '"'sMsgText'"'
  70.             doarexxrequester hDialog
  71.             action=result
  72.             freearexxrequester hDialog
  73.             if action=hDialog.cancel then signal cleanup
  74.             address command filename srcfilename tempname 'force'
  75.             commandrc = rc
  76.         end
  77.         if commandrc=ERR_NOTWORDFILE then do
  78.             call doalert 'This is not a Word file.'
  79.             exit 0
  80.         end
  81.         if commandrc>0 & commandrc~=ERR_REVUNKNOWN then do
  82.             call doalert 'An error has occured.'
  83.             exit 0
  84.         end
  85.     end
  86.     INSERTTEXT FILE tempname||'.txt' CHARSET windows STATUS
  87.     address command 'delete' tempname||'.txt quiet'
  88.     exit 0
  89.  
  90. doalert:
  91.     parse arg sAlertText
  92. /* Display an alert requester */
  93.     iAlertLength=length(sAlertText)
  94.     allocarexxrequester '"WordConverter"' iAlertLength*8+24 55
  95.     hAlertReq=result
  96.     addarexxgadget hAlertReq EXIT iALertLength*8-58 38 70 label "_Exit"
  97.     hAlert.exit=result
  98.     addarexxgadget hAlertReq TEXT 8 12 iAlertLength*8+8 border none string '"'sAlertText'"'
  99.     doarexxrequester hAlertReq
  100.     freearexxrequester hAlertReq
  101.     signal cleanup
  102.     return
  103.  
  104. cleanup:
  105.     exit
  106.